package com.jiazhong.basic.borrow.service.impl;

import com.jiazhong.basic.borrow.dao.BookDAO;
import com.jiazhong.basic.borrow.dao.BorrowDAO;
import com.jiazhong.basic.borrow.service.BorrowService;

public class BorrowServiceImpl implements BorrowService {

    private BorrowDAO bdao = new BorrowDAO();
    private BookDAO bookDAO = new BookDAO();

    @Override
    public int borrow(int userId, int bookId) {
        boolean b = bookDAO.shifouchongzu(bookId);
        if (!b) {
            return 0;
        }
        return bdao.borrow(bookId, userId);
    }

    @Override
    public int back(int userId, int bookId) {
        return bdao.back(bookId, userId);
    }
}
